package org.sy.lab.Java7并发编程实战.一线程管理.十一线程组中不可控异常的处理;

import java.util.Random;

public class Task implements Runnable {
	@Override
	public void run() {
		int result;
		Random random = new Random(Thread.currentThread().getId());
		while(true) {
			result = 1000/((int)(random.nextDouble()*1000));
			System.out.printf("%s: %d\n", Thread.currentThread().getId(), result);
			if(Thread.currentThread().isInterrupted()) {
				System.out.printf("%d: Interrupted\n", Thread.currentThread().getId());
				return;
			}
		}
	}
}
